<template>
    <el-table :data="tableData" style="width: 80%">
        <el-table-column label="发布日期" width="180">
            <template #default="scope">
                <div style="display: flex; align-items: center">
                    <el-icon>
                        <timer />
                    </el-icon>
                    <span style="margin-left: 10px">{{ scope.row.date }}</span>
                </div>
            </template>
        </el-table-column>
        <el-table-column label="文章" width="180">
            <template #default="scope">
                <div>{{ scope.row.title }}</div>
            </template>
        </el-table-column>
        <el-table-column label="审核状态" width="180">
            <template #default="scope">
                <el-result icon="success" title="审核通过" v-if="scope.row.status == 1">
                </el-result>
                <el-result icon="error" title="审核未通过" v-if="scope.row.status == 2">
                </el-result>
                <el-result icon="warning" title="审核中" v-if="scope.row.status == 0">
                </el-result>
                <!-- <el-button size="small" @click="handleEdit(scope.$index, scope.row)">Edit</el-button>
        <el-button size="small" type="danger" @click="handleDelete(scope.$index, scope.row)">Delete</el-button> -->
            </template>
        </el-table-column>
    </el-table>
</template>
  
<script lang="ts" setup>
import { Timer } from '@element-plus/icons-vue'
import { getMyArticle } from '@/api/music/music.ts'
import { onMounted, ref } from 'vue';

interface Article {
    date: string
    title: string
    status: number
}

const handleEdit = (index: number, row: User) => {
    console.log(index, row)
}
const handleDelete = (index: number, row: User) => {
    console.log(index, row)
}

const tableData: Article[] = ref([
    {
        date: '2016-05-03',
        title: 'Tom',
        status: 0
    },
    {
        date: '2016-05-02',
        title: 'Tom',
        status: 0
    },
    {
        date: '2016-05-04',
        title: 'Tom',
        status: 1
    },
    {
        date: '2016-05-01',
        title: 'Tom',
        status: 2
    },
])

onMounted(async () => {
    const res = await getMyArticle()
    tableData.value = res.articles
    console.log(tableData.value)
})


</script>
<style lang="scss" scoped>
.result {
    padding: 0px;
    height: 130px;
    width: 100px;
}
</style>